/**
  * Author: Mei
  * Date: 2020-11-22 19:25
  * Description: 
  *
  */
#include <future>
#include <thread>
#include <iostream>

void thread1(std::promise<double>& p, double val){
    std::cout << "in thread1" << std::endl;
    p.set_value(val);
}
int main(){
    std::promise<double> p;
    std::future<double> f = p.get_future();
    std::thread t1(thread1, std::ref(p), 10);
    t1.detach();

    std::cout << f.get() << std::endl;
    pthread_exit(NULL);
}